<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改持有基金')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-chiyou-edit" th:object="${jijinChiyou}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">基金代码：</label>
                <div class="col-sm-8">
                    <input id="code" name="code" th:field="*{code}" class="form-control" type="text">
                    <a class="btn btn-success" onclick="chaXun()">
                        <i class="fa"></i> 查询数据
                    </a>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">基金名称：</label>
                <div class="col-sm-8">
                    <input id="name" name="name" th:field="*{name}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">购买平台：</label>
                <div class="col-sm-8">
                    <input name="pingtai" th:field="*{pingtai}" class="form-control" type="text" list="typelist"/>
                    <datalist id="typelist">
                        <option>支付宝</option>
                        <option>蛋卷</option>
                    </datalist>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">基金组合：</label>
                <div class="col-sm-8">
                    <input name="zuhe" th:field="*{zuhe}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">单位净值：</label>
                <div class="col-sm-8">
                    <input id="jingzhi" name="jingzhi" th:field="*{jingzhi}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">涨跌幅：</label>
                <div class="col-sm-8">
                    <input id="zhangfu" name="zhangfu" th:field="*{zhangfu}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">估值：</label>
                <div class="col-sm-8">
                    <input id="guzhi" name="guzhi" th:field="*{guzhi}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">持有成本：</label>
                <div class="col-sm-8">
                    <input name="cost" th:field="*{cost}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">持有份额：</label>
                <div class="col-sm-8">
                    <input name="fene" th:field="*{fene}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">估值日期：</label>
                <div class="col-sm-8">
                    <input id="guzhiriqi" name="guzhiriqi" th:field="*{guzhiriqi}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">净值日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input id="date" name="date" th:value="*{date}" class="form-control" type="text">
                    </div>
                </div>
            </div>s
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "jijin/chiyou";
        $("#form-chiyou-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-chiyou-edit').serialize());
            }
        }
        function chaXun() {
            var code = $("#code").val();
            console.log("code="+code)
            if (code !== null && code.length === 6 ) {
                $.operate.get("/jingzhi/jiJinXinXi/"+code, function(result) {
                    if (result.code === web_status.SUCCESS) {
                        document.getElementById("name").value = result.data.name;
                        document.getElementById("jingzhi").value = result.data.jingzhi;
                        document.getElementById("date").value = result.data.date;
                        document.getElementById("zhangfu").value = result.data.zhangfu;
                        document.getElementById("guzhi").value = result.data.guzhi;
                        document.getElementById("guzhiriqi").value = result.data.guzhiriqi;
                    }
                });
            }
        }

        $("input[name='date']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>